# Maintainer: Muflone http://www.muflone.com/contacts/english/
# Contributor: <michael dot kogan at gmx dot net>
# Contributor: John D Jones III AKA jnbek <jnbek1972 -_AT_- g m a i l -_Dot_- com>

pkgname=perl-json-maybexs
_perl_namespace=JSON
_perl_module=MaybeXS
pkgver=1.004004
pkgrel=1
pkgdesc="Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP"
arch=('any')
license=('PerlArtistic' 'GPL')
depends=('perl')
makedepends=('perl-test-needs' 'perl-cpanel-json-xs')
optdepends=('perl-cpanel-json-xs: Using Cpanel-JSON-XS')
options=('!emptydirs')
url="https://metacpan.org/dist/${_perl_namespace}-${_perl_module}"
source=("https://cpan.metacpan.org/authors/id/E/ET/ETHER/${_perl_namespace}-${_perl_module}-${pkgver}.tar.gz")
sha256sums=('7ca5921306a544f621705dce987fe955b1a6833d0b195c094626a19dca094dba')

build() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps
  perl Makefile.PL
  make
}

check() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1
  make test
}

package() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  make pure_install INSTALLDIRS=vendor DESTDIR="${pkgdir}"
  # Delete unuseful files
  find "${pkgdir}" -name '.packlist' -delete
}
